﻿
using System.Threading.Tasks;
using System.Windows;
using Red.Core;

namespace Red.Controls.Shell
{
    /// <summary>
    ///     Interface for a host application implementation
    /// </summary>
    public interface IEditorHost
    {
        /// <summary>
        ///     If there is an editor with the same dllName and instanceContext, it's brought to front.
        ///     If not, a new instance is created and shown. If creation failed, an appropriate message is shown.
        /// </summary>
        /// <param name="editorName">
        ///     Editor name of a editor plug-in to be loaded (without an extension)
        /// </param>
        /// <param name="instanceContext">
        ///     Identifies unique instance of the editor. Usually it's a path to a resource being edited.
        ///     This value is passed to the editor's main window constructor.
        /// </param>
        /// <param name="filePath">
        ///     File path of the resource that will be currently edited.
        /// </param>
        /// <param name="msgParent">
        ///     Parent window for possible error message. E.g. if you are calling this from inside a control, you may use Window.GetWindow( yourControl ).
        /// </param>
        /// <param name="additionalParams"></param>
        /// <returns>
        ///     Returns <see langword="true"/> if the launch succeeded
        /// </returns>
        Task<bool> LaunchEditorAsync( string editorName, string instanceContext, CommandLineDictionary additionalParams, Window msgParent = null );

        /// <summary>
        ///     Opens an appropriate editor for given resource. It there is already an editor open for this resource, it's brought to front.
        ///     If not, a new instance is created and shown. If creation failed, an appropriate message is shown.
        /// </summary>
        /// <param name="path">
        ///     Full path to the resource you want to open editor for.
        /// </param>
        /// <param name="msgParent">
        ///     Parent window for possible error message. E.g. if you are calling this from inside a control, you may use Window.GetWindow( yourControl ).
        /// </param>
        /// <returns>
        ///     Returns <see langword="true"/> if the launch succeeded
        /// </returns>
        Task<bool> EditResourceAsync( string path, Window msgParent = null );

        /// <summary>
        ///     Shows the given resource in the browser
        /// </summary>
        /// <param name="path">
        /// </param>
        /// <param name="msgParent">
        /// </param>
        /// <returns>
        ///     Returns <see langword="true"/> if the function succeeded
        /// </returns>
        Task<bool> ShowResourceAsync( string path );
    }
}